/**
  * @file     	timer.c
  * @author   	YangHaifeng
  * @email   	2995339193@qq.com
  * @version	V0.0
  * @license  	GNU General Public License (GPL)  
  * @detail		please follow the license!!!
  * @attention
  *  this file is aim to do something with timer									
  *   																	
  * @htmlonly 
  * <span style="font-weight: bold">History</span> 
  * @endhtmlonly 
  * Version|Auther|Describe
  * ------|----|-------- 
  * V0.0|YangHaifeng|Create File
  * <h2><center>&copy;COPYRIGHT YangHaifeng All Rights Reserved.</center></h2>
  */ 
  
#include "timer.h"


/**
 * @brief 定时器32初始化
 * @param None
 * @retval None
 * @author YangHaifeng
 */
void timer_init(uint32_t psc,uint32_t arr)
{
	//初始化为32位周期计数模式
	Timer32_initModule(TIMER32_0_BASE,psc,TIMER32_32BIT,TIMER32_PERIODIC_MODE);


	//设置ARR自动重装载值
	Timer32_setCount(TIMER32_0_BASE,arr);	
	
	
	//配置定时器32开始连续计数
	Timer32_startTimer(TIMER32_0_BASE,false);
	
	
	//清除中断标志位
	Timer32_clearInterruptFlag(TIMER32_0_BASE);
	
	
	//使能定时器32中断
	Timer32_enableInterrupt(TIMER32_0_BASE);
	
	
	//开启定时器32端口中断
	Interrupt_enableInterrupt(INT_T32_INT1);
	
	
	//开启总中断
	Interrupt_enableMaster();
}



/**
 * @brief 定时器32中断服务函数
 * @param None
 * @retval None
 * @author YangHaifeng
 */
void T32_INT1_IRQHandler(void)
{
    Timer32_clearInterruptFlag(TIMER32_0_BASE);
	main_task();
}





